<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>花店销售查询页面</title>
		<link rel="stylesheet" type="text/css" href="css/manager.css"/>
		<script type="text/javascript" src="js/jquery.js"></script>
<%--		<script type="text/javascript" src="js/manager.js"></script>--%>

		<script type="text/javascript">
			function add() {
				location.href="addteacher.jsp";
			}
			function checkDelete(id) {
				var ans = confirm("确认删除此记录吗？");
				if (ans) {
					location.href = "delete?id=" + id;
					return true;
				}
				return false;
			}

			function pagenavigate(frm,pageIndex){
				frm.pageIndex.value = pageIndex;
				frm.submit();
			}

			function jumpto(frm,pageIndex,pageCount) {
				//验证用户的输入
				var regexp=/^[1-9]\d*$/;
				if(!regexp.test(pageIndex)){
					alert("请输入大于0的正整数！");
					return false;
				}else if((pageIndex-pageCount) > 0) {
					pagenavigate(frm,pageCount);
				}else{
					pagenavigate(frm,pageIndex);
				}
			}
		</script>
	</head>
	<body>
		<p>花店销售查询</p>
		<a href="../index.jsp">返回首页</a><br/>
		<div class="list">
			<span style="float: right;"><input type="button" value="添加" class="btnadd" onclick="add();" /></span>
			<div>
				<form action="search" method="post">
					销售单号:<input type="text" width="10px" name="id" value="${search.id==0?"":search.id}" />
					名称:<input type="text" width="10px" name="name" value="${search.name}" />
					是否收到:
					<select name="isreceived">
						<option value="0" <c:if test="${isreceived=='0'}">selected="selected"</c:if>>请选择...</option>
						<option value="true" <c:if test="${isreceived=='true'}">selected="selected"</c:if>>是</option>
						<option value="false" <c:if test="${isreceived=='false'}">selected="selected"</c:if>>否</option>
					</select>
					<input type="submit" name="btnSubmit" value="查询" />
					<input type="hidden" name="pageIndex" value="1"/>
				</form>
			</div>
			<table border="1" cellspacing="0" cellpadding="0" width="100%" id="table">
				<tr>
					<td>销售单号</td>
					<td>名称</td>
					<td>是否收到</td>
					<td>价格</td>
					<td>照片</td>
					<td>销售日期</td>
					<td>类别</td>
					<td>操作</td>
				</tr>
				<c:forEach var="t" items="${sessionScope.teachers}">
					<tr>
						<td>${t.id}</td>
						<td>${t.name}</td>
						<td>${t.isreceived?"是":"否"}</td>
						<td>${t.price}</td>
						<td>
							<img src="${pageContext.request.contextPath }/files/${t.photo}" width="60px" height="80px" />
						</td>
						<td>${t.sdate}</td>
						<td>${t.province.name}</td>
						<td>
							<a href="detail?id=${t.id}">查看</a>
							<a href="detail?id=${t.id}&edit=1">修改</a>
							<a href="javascript:checkDelete(${t.id})">删除</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div>
			<!-- 分页显示 -->
			<a href="javascript:pagenavigate(document.forms[0],1)">首页</a>
			<a href="javascript:pagenavigate(document.forms[0],${page.pageIndex<page.pageCount?page.pageIndex+1:page.pageCount})">下一页</a>
			<a href="javascript:pagenavigate(document.forms[0],${page.pageIndex>1?page.pageIndex-1:1})">上一页</a>
			<a href="javascript:pagenavigate(document.forms[0],${page.pageCount})">末页</a>
			<!-- 显示页码 -->
			第${page.pageIndex}页 / 共${page.pageCount}页
			&nbsp;&nbsp;&nbsp;&nbsp;
			<!-- 页码跳转 -->
			跳转到：<input type="text" size="5" id="txtJumpto"  />
			<input type="button" value="GO" onclick="jumpto(document.forms[0],document.getElementById('txtJumpto').value,${page.pageCount})" />
		</div>
	</body>
</html>
